<template>
  <img v-if="isDefault" src="@/assets/user1-128x128.jpg"/>
  <img v-else :src="realSrc" @error="isDefault=false"/>
</template>

<script>
  import utils from '@/utils';

  export default {
    name: 'Avatar',
    props: {
      src: {
        type: String
      }
    },
    data() {
      return {
        isDefault: false
      };
    },
    mounted() {
      this.isDefault = !this.src;
    },
    computed: {
      realSrc() {
        return `${utils.baseUrl}${this.src}`;
      }
    }
  };
</script>

<style scoped>

</style>
